.popup-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  padding: 20px;
  overflow: hidden;
}

.popup-content {
  background: white;
  border-radius: 12px;
  padding: 16px;
  width: 90%;
  max-width: 800px;
  position: relative;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  margin: auto;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.popup-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: none;
  border: none;
  font-size: 24px;
  color: #64748b;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  transition: all 0.2s;
}

.popup-close:hover {
  background: #f1f5f9;
  color: #1e293b;
}

.popup-header {
  text-align: center;
  margin-bottom: 8px;
}

.popup-header h2 {
  margin: 0;
  color: #1e293b;
  font-size: 24px;
}

.popup-body {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* Settings Popup Styles */
.settings-content {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: calc(90vh - 100px);
  overflow-y: auto;
  padding-right: 8px;
}

.settings-content::-webkit-scrollbar {
  width: 6px;
}

.settings-content::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 3px;
}

.settings-content::-webkit-scrollbar-thumb {
  background: #888;
  border-radius: 3px;
}

.settings-content::-webkit-scrollbar-thumb:hover {
  background: #555;
}

.settings-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  background-color: #f8fafc;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
  margin-bottom: 8px;
}

.settings-section h3 {
  margin: 0;
  color: #1e293b;
  font-size: 16px;
  font-weight: 600;
  text-align: left;
}

.settings-subsection {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px;
  background-color: #fff;
  border-radius: 6px;
  border: 1px solid #e2e8f0;
  margin-bottom: 4px;
}

.settings-subsection h4 {
  margin: 0;
  color: #475569;
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 4px;
}

.settings-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.settings-row label {
  min-width: 60px;
  color: #475569;
  font-size: 14px;
}

.settings-row input[type="number"],
.settings-row input[type="text"] {
  width: 60px;
  padding: 4px 8px;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  font-size: 14px;
  color: #1e293b;
  background-color: #ffffff;
}

.settings-row span {
  color: #475569;
  font-size: 14px;
}

.settings-select {
  width: 100px;
  padding: 4px 8px;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  font-size: 14px;
  color: #1e293b;
  background-color: #ffffff;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748b' d='M6 8.825L1.175 4 2.238 2.938 6 6.7l3.763-3.763L10.825 4z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  padding-right: 28px;
}

.settings-select:focus {
  outline: none;
  border-color: #646cff;
  box-shadow: 0 0 0 2px rgba(100, 108, 255, 0.1);
}

.settings-select:hover {
  border-color: #94a3b8;
}

.settings-row input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: #3b82f6;
  background-color: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  appearance: none;
  -webkit-appearance: none;
  position: relative;
}

.settings-row input[type="checkbox"]:checked {
  background-color: #3b82f6;
  border-color: #3b82f6;
}

.settings-row input[type="checkbox"]:checked::after {
  content: "✓";
  position: absolute;
  color: white;
  font-size: 12px;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.settings-actions {
  display: flex;
  justify-content: center;
  margin-top: 8px;
}

/* Help Popup Styles */
.help-content {
  padding: 16px;
  background-color: #f8fafc;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
}

.help-text {
  color: #475569;
  line-height: 1.8;
  font-size: 14px;
  white-space: pre-wrap;
}

/* Game End Popup Styles */
.answer-character {
  display: flex;
  align-items: flex-start;
  gap: 24px;
  padding: 16px;
  background: #f8fafc;
  border-radius: 8px;
}

.answer-character-image {
  width: 200px;
  height: 280px;
  object-fit: cover;
  object-position: top;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  flex-shrink: 0;
}

.answer-character-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.character-name-container {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  position: relative;
}

.character-link {
  text-decoration: none;
  color: inherit;
  transition: color 0.2s;
  flex: 1;
}

.character-link:hover {
  color: #646cff;
}

.answer-character-name {
  font-size: 28px;
  font-weight: 600;
  color: #1e293b;
}

.button-container {
  position: absolute;
  right: 0;
  top: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.contribute-tag-btn {
  font-size: 16px;
  padding: 8px 20px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  color: #64748b;
  cursor: pointer;
  transition: all 0.2s;
  font-weight: 500;
}

.button-icon {
  width: 72px;
  height: 72px;
  border-radius: 8px;
  object-fit: cover;
}

.contribute-tag-btn:hover {
  background: #e2e8f0;
  color: #1e293b;
}

.answer-character-name-cn {
  font-size: 18px;
  color: #64748b;
}

/* 角色信息部分样式 */
.answer-summary,
.answer-appearances,
.answer-tags {
  margin-top: 16px;
  font-size: 14px;
  color: #666;
  line-height: 1.5;
  max-height: 200px;
  overflow-y: auto;
  padding-right: 10px;
}

.answer-summary h3,
.answer-appearances h3,
.answer-tags h3 {
  margin: 0 0 8px 0;
  font-size: 16px;
  font-weight: 600;
  color: #1e293b;
}

.appearances-list {
  margin: 0;
  padding-left: 20px;
  color: #475569;
  line-height: 1.6;
}

.appearances-list li {
  margin-bottom: 4px;
}

.tags-container {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.character-tag {
  display: inline-block;
  padding: 4px 10px;
  background: #e2e8f0;
  border-radius: 16px;
  font-size: 14px;
  color: #475569;
}

.more-tags {
  display: inline-block;
  padding: 4px 10px;
  background: #cbd5e0;
  border-radius: 16px;
  font-size: 14px;
  color: #1e293b;
}

.answer-summary::-webkit-scrollbar {
  width: 6px;
}

.answer-summary::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 3px;
}

.answer-summary::-webkit-scrollbar-thumb {
  background: #888;
  border-radius: 3px;
}

.answer-summary::-webkit-scrollbar-thumb:hover {
  background: #555;
}

.summary-content {
  color: #475569;
  line-height: 1.6;
  font-size: 14px;
  white-space: pre-wrap;
}

.filter-row {
  display: flex;
  align-items: center;
  gap: 32px;
  justify-content: flex-start;
}

.filter-item {
  display: flex;
  align-items: center;
  gap: 8px;
}

.filter-item label {
  min-width: 40px;
  color: #475569;
  font-size: 14px;
}

.settings-row input:disabled,
.settings-select:disabled {
  background-color: #f1f5f9;
  cursor: not-allowed;
  opacity: 0.7;
}

.index-input-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.index-prefix {
  color: #64748b;
  font-size: 14px;
  white-space: nowrap;
}

.index-input-group input {
  width: 120px;
  padding: 4px 8px;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  font-size: 14px;
  color: #1e293b;
}

.import-button {
  padding: 4px 12px;
  background-color: #3b82f6;
  color: white;
  border: none;
  border-radius: 4px;
  font-size: 14px;
  cursor: pointer;
  transition: background-color 0.2s;
}

.import-button:hover {
  background-color: #2563eb;
}

.index-info {
  margin-top: 8px;
  padding: 12px;
  background-color: #f1f5f9;
  border-radius: 4px;
  border: 1px solid #e2e8f0;
}

.index-info-content {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.index-title {
  font-weight: 500;
  color: #1e293b;
}

.index-total {
  color: #64748b;
  font-size: 0.9em;
}

.search-box {
  display: flex;
  gap: 8px;
  width: 100%;
  height: 40px;
}

.search-box input {
  flex: 1;
  padding: 8px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 14px;
}

.search-box button {
  padding: 8px 16px;
  background-color: #4a90e2;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
}

.search-box button:hover {
  background-color: #357abd;
}

.search-results {
  margin-top: 12px;
  max-height: 200px;
  overflow-y: auto;
  border: 1px solid #ddd;
  border-radius: 4px;
}

.search-result-item {
  padding: 8px 12px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #eee;
}

.search-result-item:last-child {
  border-bottom: none;
}

.search-result-item:hover {
  background-color: #f5f5f5;
}

.subject-title {
  font-weight: 500;
}

.subject-meta, .subject-type {
  color: #64748b;
  font-size: 0.9em;
}

.subject-type {
  margin-left: auto;
}

.added-subjects {
  margin-top: 16px;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  padding: 12px;
}

.added-subjects h5 {
  margin: 0 0 8px 0;
  color: #475569;
  font-size: 14px;
  font-weight: 500;
}

.added-subject-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background-color: #f8fafc;
  border-radius: 4px;
  margin-bottom: 4px;
  border: 1px solid #e2e8f0;
}

.added-subject-item:last-child {
  margin-bottom: 0;
}

.subject-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.subject-title {
  font-weight: 500;
  color: #1e293b;
}

.subject-meta {
  color: #64748b;
  font-size: 0.9em;
}

.remove-button {
  background: none;
  border: none;
  color: #ef4444;
  font-size: 18px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  transition: all 0.2s;
}

.remove-button:hover {
  background-color: #fee2e2;
  color: #dc2626;
}

.presets-buttons {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
}

.preset-button {
  padding: 8px 16px;
  border: 1px solid #ddd;
  border-radius: 4px;
  background-color: #fff;
  color: #333;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.preset-button:hover {
  background-color: #f5f5f5;
  border-color: #ccc;
}

.preset-button:active {
  background-color: #e5e5e5;
}

@media (max-width: 640px) {
  .popup-content {
    padding: 16px;
    width: 100%;
    max-height: calc(100vh - 32px);
  }

  .popup-overlay {
    padding: 16px;
  }

  .answer-character {
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 16px;
  }

  .answer-character-image {
    width: 150px;
    height: 210px;
  }

  .answer-character-name {
    font-size: 24px;
  }

  .answer-character-name-cn {
    font-size: 16px;
  }

  .character-name-container {
    flex-direction: column;
    align-items: center;
    margin-bottom: 16px;
  }

  .button-container {
    position: relative;
    margin-top: 16px;
    right: auto;
    top: auto;
  }

  .answer-appearances h3,
  .answer-tags h3,
  .answer-summary h3 {
    text-align: center;
  }

  .tags-container {
    justify-content: center;
  }
}

@media (prefers-color-scheme: dark) {
  .settings-row input[type="number"],
  .settings-row input[type="text"],
  .settings-select {
    background-color: #ffffff;
    color: #1e293b;
  }

  .settings-row input[type="checkbox"] {
    background-color: #ffffff;
    border-color: #e2e8f0;
  }

  .settings-row input[type="checkbox"]:checked {
    background-color: #3b82f6;
    border-color: #3b82f6;
  }
}

.popup-footer {
  margin-top: 16px;
  flex-shrink: 0;
}

/* Tooltip styles */
.tooltip-trigger {
  position: relative;
  display: inline-block;
  margin-left: 4px;
  width: 16px;
  height: 16px;
  line-height: 16px;
  text-align: center;
  background-color: #e2e8f0;
  color: #64748b;
  border-radius: 50%;
  font-size: 12px;
  cursor: help;
}

.tooltip-text {
  visibility: hidden;
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background-color: #ffffff;
  color: #1e293b;
  text-align: left;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 12px;
  line-height: 1.5;
  z-index: 1;
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
  width: max-content;
  max-width: 200px;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  border: 1px solid #e2e8f0;
  white-space: normal;
  word-wrap: break-word;
}

.tooltip-text::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  margin-left: -5px;
  border-width: 5px;
  border-style: solid;
  border-color: #ffffff transparent transparent transparent;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.1));
}

.tooltip-trigger:hover .tooltip-text {
  visibility: visible;
  opacity: 1;
}

/* Tag Contribution Popup Styles */
.tag-contribution-container {
  display: flex;
  flex-direction: column;
  gap: 24px;
  height: 100%;
  overflow: hidden;
}

.character-preview {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-bottom: 16px;
  border-bottom: 1px solid #e2e8f0;
}

.character-preview-image {
  width: 150px;
  height: 200px;
  object-fit: contain;
  border-radius: 8px;
  margin-bottom: 10px;
}

.character-preview-info {
  text-align: center;
  margin-bottom: 10px;
}

.character-preview-name {
  font-size: 1.2em;
  font-weight: bold;
}

.character-preview-name-cn {
  font-size: 1em;
  color: #666;
}

.author-notes {
  flex: 1;
  padding: 4px 8px;
  color: #64748b;
  font-size: 14px;
  line-height: 1.5;
  background: #fff;
  border-radius: 4px;
  display: flex;
  align-items: center;
  min-height: 112px;
}

.tag-input-section {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding-right: 8px;
}

.tag-input-section::-webkit-scrollbar {
  width: 8px;
}

.tag-input-section::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 4px;
}

.tag-input-section::-webkit-scrollbar-thumb {
  background: #888;
  border-radius: 4px;
}

.tag-input-section::-webkit-scrollbar-thumb:hover {
  background: #555;
}

.tag-input-group {
  display: flex;
  gap: 8px;
}

.tag-input {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  font-size: 16px;
  color: #1e293b;
}

.tag-input:focus {
  outline: none;
  border-color: #646cff;
  box-shadow: 0 0 0 2px rgba(100, 108, 255, 0.1);
}

.add-tag-btn {
  padding: 8px 16px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  color: #64748b;
  font-size: 16px;
  cursor: pointer;
  transition: all 0.2s;
}

.add-tag-btn:hover {
  background: #e2e8f0;
  color: #1e293b;
}

.tag-suggestions {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.tag-suggestions h4 {
  margin: 0;
  color: #64748b;
  font-size: 14px;
  font-weight: 500;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag-suggestion {
  padding: 6px 12px;
  background: #f1f5f9;
  border: none;
  border-radius: 16px;
  color: #475569;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
  outline: none;
}

.tag-suggestion:focus {
  outline: none;
}

.tag-suggestion:hover {
  background: #e2e8f0;
  color: #1e293b;
}

.tag-suggestion.selected {
  background: #646cff;
  color: white;
}

.tag-suggestion.selected:hover {
  background: #4f46e5;
}

.submit-tags-btn {
  width: 100%;
  padding: 12px;
  background: #646cff;
  border: none;
  border-radius: 6px;
  color: white;
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.submit-tags-btn:hover {
  background: #4f46e5;
}

.tag-groups {
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding-bottom: 16px;
}

.tag-group {
  background: #f8fafc;
  border-radius: 8px;
  padding: 16px;
}

.tag-group-title {
  margin: 0 0 12px 0;
  color: #1e293b;
  font-size: 16px;
  font-weight: 500;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag-suggestion {
  padding: 6px 12px;
  background: #f1f5f9;
  border: none;
  border-radius: 16px;
  color: #475569;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
  outline: none;
}

.custom-tag-input {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.custom-tag-input input {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  font-size: 14px;
  color: #1e293b;
}

.custom-tag-input input:focus {
  outline: none;
  border-color: #646cff;
  box-shadow: 0 0 0 2px rgba(100, 108, 255, 0.1);
}

.custom-tag-input input.has-error {
  border-color: #ef4444;
}

.custom-tag-input button {
  padding: 8px 16px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  color: #64748b;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
}

.custom-tag-input button:hover {
  background: #e2e8f0;
  color: #1e293b;
}

.input-error {
  color: #ef4444;
  font-size: 12px;
  margin-top: -8px;
  margin-bottom: 8px;
}

.custom-tags-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.custom-tag {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  background: #e2e8f0;
  border-radius: 16px;
  font-size: 14px;
  color: #1e293b;
}

.custom-tag button {
  background: none;
  border: none;
  color: #64748b;
  font-size: 16px;
  cursor: pointer;
  padding: 0 2px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.custom-tag button:hover {
  color: #ef4444;
}

.tag-suggestion.disabled {
  opacity: 0.5;
  cursor: not-allowed;
  background: #e2e8f0;
}

.tag-suggestion.disabled:hover {
  background: #e2e8f0;
  color: #475569;
}

.custom-tag-input input:disabled,
.custom-tag-input button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  background: #e2e8f0;
}

.submit-tags-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  background: #94a3b8;
}

.submit-tags-btn:disabled:hover {
  background: #94a3b8;
}
